home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / H / nodes / primnodes.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  10.6 KB  |  369 lines

  1. /* ----------------------------------------------------------------
  2.  *   FILE
  3.  *    primnodes.h
  4.  *    
  5.  *   DESCRIPTION
  6.  *    Definitions for parse tree/query tree ("primitive") nodes.
  7.  *
  8.  *   NOTES
  9.  *    this file is listed in lib/Gen/inherits.sh and in the
  10.  *    INH_SRC list in conf/inh.mk and is used to generate the
  11.  *    obj/lib/C/primnodes.c file
  12.  *
  13.  *    For explanations of what the structure members mean,
  14.  *    see ~postgres/doc/query-tree.t.
  15.  *
  16.  *   IDENTIFICATION
  17.  *    $Header: /private/postgres/src/lib/H/nodes/RCS/primnodes.h,v 1.45 1992/07/26 17:04:43 mer Exp $
  18.  * ----------------------------------------------------------------
  19.  */
  20.  
  21. #ifndef PrimNodesIncluded
  22. #define    PrimNodesIncluded
  23.  
  24. #include "tmp/postgres.h"
  25.  
  26. #include "access/att.h"
  27. #include "access/attnum.h"
  28. #include "storage/buf.h"
  29. #include "utils/rel.h"
  30. #include "utils/fcache.h"
  31. #include "rules/params.h"
  32.  
  33. #include "nodes/nodes.h"    /* bogus inheritance system */
  34. #include "nodes/pg_lisp.h"
  35. #include "nodes/primnodes.gen"
  36.  
  37. /* ----------------------------------------------------------------
  38.  *    Node Function Declarations
  39.  *    
  40.  *  All of these #defines indicate that we have written print/equal/copy
  41.  *  support for the classes named.  The print routines are in
  42.  *  lib/C/printfuncs.c, the equal functions are in lib/C/equalfincs.c and
  43.  *  the copy functions can be found in lib/C/copyfuncs.c
  44.  *
  45.  *  An interface routine is generated automatically by Gen_creator.sh for
  46.  *  each node type.  This routine will call either do nothing or call
  47.  *  an _print, _equal or _copy function defined in one of the above
  48.  *  files, depending on whether or not the appropriate #define is specified.
  49.  *
  50.  *  Thus, when adding a new node type, you have to add a set of
  51.  *  _print, _equal and _copy functions to the above files and then
  52.  *  add some #defines below.
  53.  *
  54.  *  This is pretty complicated, and a better-designed system needs to be
  55.  *  implemented.
  56.  * ----------------------------------------------------------------
  57.  */
  58.  
  59. /* ----------------
  60.  *    Node Out Function declarations
  61.  * ----------------
  62.  */
  63. #define    OutResdomExists
  64. #define    OutExprExists
  65. #define    OutParamExists
  66. #define    OutFuncExists
  67. #define    OutOperExists
  68. #define OutConstExists
  69. #define OutVarExists
  70. #define OutArrayExists
  71. #define OutArrayRefExists
  72. #define OutFjoinExists
  73.  
  74. /* ----------------
  75.  *    Node Equal Function declarations
  76.  * ----------------
  77.  */
  78. #define    EqualResdomExists
  79. #define    EqualExprExists
  80. #define    EqualParamExists
  81. #define    EqualFuncExists
  82. #define    EqualOperExists
  83. #define EqualConstExists
  84. #define EqualVarExists
  85. #define EqualArrayExists
  86. #define EqualArrayRefExists
  87. #define EqualFjoinExists
  88.  
  89. /* ----------------
  90.  *    Node Copy Function declarations
  91.  * ----------------
  92.  */
  93. #define    CopyResdomExists
  94. #define    CopyExprExists
  95. #define    CopyParamExists
  96. #define    CopyFuncExists
  97. #define    CopyOperExists
  98. #define CopyConstExists
  99. #define CopyVarExists
  100. #define CopyArrayExists
  101. #define CopyArrayRefExists
  102. #define CopyFjoinExists
  103.  
  104.  
  105. /* ----------------------------------------------------------------
  106.  *            node definitions
  107.  * ----------------------------------------------------------------
  108.  */
  109.  
  110. /* ----------------
  111.  * Resdom
  112.  *    resno        - XXX comment me.
  113.  *    restype        - XXX comment me.
  114.  *      rescomplex      - is the restype complex?
  115.  *    reslen        - XXX comment me.
  116.  *    resname        - XXX comment me.
  117.  *    reskey        - XXX comment me.
  118.  *    reskeyop    - XXX comment me.
  119.  *    resjunk        - set to nonzero to eliminate the attribute
  120.  *              from final target list  e.g., ctid for replace
  121.  *              and delete
  122.  *
  123.  *    XXX reskeyop is USED as an int within the print functions
  124.  *        so that's what the copy function uses so if its
  125.  *        in fact an int, then the OperatorTupleForm declaration
  126.  *        below is incorrect.  -cim 5/1/90
  127.  * ----------------
  128.  */
  129. class (Resdom) public (Node) {
  130.  /* private: */
  131.     inherits0(Node);
  132.     AttributeNumber        resno;
  133.     ObjectId        restype;
  134.     bool                    rescomplex;
  135.     Size            reslen;
  136.     Name            resname;
  137.     Index            reskey;
  138.     OperatorTupleForm    reskeyop; 
  139.     int            resjunk;
  140.  /* public: */
  141. };
  142.  
  143. /* -------------
  144.  * Fjoin
  145.  *      initialized    - true if the Fjoin has already been initialized for
  146.  *                        the current target list evaluation
  147.  *    nNodes        - The number of Iter nodes returning sets that the
  148.  *              node will flatten
  149.  *    outerList    - 1 or more Iter nodes
  150.  *    inner        - exactly one Iter node.  We eval every node in the
  151.  *              outerList once then eval the inner node to completion
  152.  *              pair the outerList result vector with each inner
  153.  *              result to form the full result.  When the inner has
  154.  *              been exhausted, we get the next outer result vector
  155.  *              and reset the inner.
  156.  *    results        - The complete (flattened) result vector
  157.  *      alwaysNull    - a null vector to indicate sets with a cardinality of
  158.  *              0, we treat them as the set {NULL}.
  159.  */
  160. class (Fjoin) public (Node) {
  161.     inherits0(Node);
  162.     bool            fj_initialized;
  163.     int            fj_nNodes;
  164.     List            fj_innerNode;
  165.     DatumPtr        fj_results;
  166.     BoolPtr            fj_alwaysDone;
  167. };
  168.  
  169. /* ----------------
  170.  * Expr
  171.  * ----------------
  172.  */
  173. class (Expr) public (Node) {
  174. #define    ExprDefs \
  175.     inherits0(Node)
  176.  /* private: */
  177.     ExprDefs;
  178.  /* public: */
  179. };
  180.  
  181. /* ----------------
  182.  * Var
  183.  *    varno         - index of this var's relation in the range table
  184.  *    varattno     - attribute number of this var
  185.  *    vartype     - pg_type tuple oid for the type of this var
  186.  *    varid         - cons cell containing (varno, (varattno))
  187.  *    varslot     - cached pointer to addr of expr cxt slot
  188.  * ----------------
  189.  */
  190. class (Var) public (Expr) {
  191.  /* private: */
  192.     inherits1(Expr);
  193.     Index            varno; 
  194.     AttributeNumber        varattno;
  195.     ObjectId        vartype;
  196.     List            varid;
  197.     Pointer            varslot;
  198.  /* public: */
  199. };
  200.  
  201. /* ----------------
  202.  * Oper
  203.  *    opno         - PG_OPERATOR OID of the operator
  204.  *    opid         - PG_PROC OID for the operator
  205.  *    oprelationlevel - true iff the operator is relation-level
  206.  *    opresulttype     - PG_TYPE OID of the operator's return value
  207.  *    opsize         - size of return result (cached by executor)
  208.  *    op_fcache    - XXX comment me.
  209.  *
  210.  * ----
  211.  * NOTE: in the good old days 'opno' used to be both (or either, or
  212.  * neither) the pg_operator oid, and/or the pg_proc oid depending 
  213.  * on the postgres module in question (parser->pg_operator,
  214.  * executor->pg_proc, planner->both), the mood of the programmer,
  215.  * and the phase of the moon (rumors that it was also depending on the day
  216.  * of the week are probably false). To make things even more postgres-like
  217.  * (i.e. a mess) some comments were referring to 'opno' using the name
  218.  * 'opid'. Anyway, now we have two separate fields, and of course that
  219.  * immediately removes all bugs from the code...    [ sp :-) ].
  220.  * ----------------
  221.  */
  222. class (Oper) public (Expr) {
  223.  /* private: */
  224.     inherits1(Expr);
  225.     ObjectId        opno;
  226.     ObjectId        opid;
  227.     bool            oprelationlevel;
  228.     ObjectId        opresulttype;
  229.     int            opsize;
  230.     FunctionCachePtr    op_fcache;
  231.  /* public: */
  232. };
  233.  
  234.  
  235. /* ----------------
  236.  * Const
  237.  *    consttype - PG_TYPE OID of the constant's value
  238.  *    constlen - length in bytes of the constant's value
  239.  *    constvalue - the constant's value
  240.  *    constisnull - whether the constant is null 
  241.  *        (if true, the other fields are undefined)
  242.  *    constbyval - whether the information in constvalue
  243.  *        if passed by value.  If true, then all the information
  244.  *        is stored in the datum. If false, then the datum
  245.  *        contains a pointer to the information.
  246.  * ----------------
  247.  */
  248. class (Const) public (Expr) {
  249.  /* private: */
  250.     inherits1(Expr);
  251.     ObjectId        consttype;
  252.     Size            constlen;
  253.     Datum            constvalue;
  254.     bool            constisnull;
  255.     bool            constbyval;
  256.  /* public: */
  257. };
  258.  
  259. /* ----------------
  260.  * Param
  261.  *    paramkind - specifies the kind of parameter. The possible values
  262.  *    for this field are specified in "params.h", and they are:
  263.  *
  264.  *     PARAM_NAMED: The parameter has a name, i.e. something
  265.  *              like `$.salary' or `$.foobar'.
  266.  *              In this case field `paramname' must be a valid Name.
  267.  *
  268.  *    PARAM_NUM:   The parameter has only a numeric identifier,
  269.  *              i.e. something like `$1', `$2' etc.
  270.  *              The number is contained in the `paramid' field.
  271.  *
  272.  *     PARAM_NEW:   Used in PRS2 rule, similar to PARAM_NAMED.
  273.  *                  The `paramname' and `paramid' refer to the "NEW" tuple
  274.  *             The `pramname' is the attribute name and `paramid'
  275.  *                 is the attribute number.
  276.  *
  277.  *    PARAM_OLD:   Same as PARAM_NEW, but in this case we refer to
  278.  *              the "OLD" tuple.
  279.  *
  280.  *    paramid - numeric identifier for literal-constant parameters ("$1")
  281.  *    paramname - attribute name for tuple-substitution parameters ("$.foo")
  282.  *    paramtype - PG_TYPE OID of the parameter's value
  283.  *      param_tlist - allows for projection in a param node.
  284.  * ----------------
  285.  */
  286. class (Param) public (Expr) {
  287.  /* private: */
  288.     inherits1(Expr);
  289.     int            paramkind;
  290.     AttributeNumber        paramid;
  291.     Name            paramname;
  292.     ObjectId        paramtype;
  293.     List                    param_tlist;
  294.  /* public: */
  295. };
  296.  
  297.  
  298. /* ----------------
  299.  * Func
  300.  *    funcid         - PG_FUNCTION OID of the function
  301.  *    functype     - PG_TYPE OID of the function's return value
  302.  *    funcisindex     - the function can be evaluated by scanning an index
  303.  *              (set during query optimization)
  304.  *    funcsize     - size of return result (cached by executor)
  305.  *    func_fcache     - XXX comment me.
  306.  *      func_tlist      - projection of functions returning tuples
  307.  *      func_planlist   - result of planning this func, if it's a PQ func
  308.  * ----------------
  309.  */
  310. class (Func) public (Expr) {
  311.  /* private: */
  312.     inherits1(Expr);
  313.     ObjectId        funcid;
  314.     ObjectId        functype;
  315.     bool            funcisindex;
  316.     int            funcsize;
  317.     FunctionCachePtr    func_fcache;
  318.     List                    func_tlist;
  319.     List                    func_planlist;
  320.  /* public: */
  321. };
  322.  
  323. /* ----------------
  324.  * Array
  325.  *    arrayelemtype    - base type of the array's elements (homogenous!)
  326.  *    arrayelemlength    - length of that type
  327.  *    arrayelembyval    - can you pass this element by value?
  328.  *    arraylow    - base for array indexing
  329.  *    arrayhigh    - limit for array indexing
  330.  *    arraylen    - ((high - low) + 1) * elemlength, or -1
  331.  * ----------------
  332.  *
  333.  *  memo from mao:  the array support we inherited from 3.1 is just
  334.  *  wrong.  when time exists, we should redesign this stuff to get
  335.  *  around a bunch of unfortunate implementation decisions made there.
  336.  */
  337. class (Array) public (Expr) {
  338.  /* private: */
  339.     inherits1(Expr);
  340.     ObjectId        arrayelemtype;
  341.     int            arrayelemlength;
  342.     bool            arrayelembyval;
  343.     int            arraylow;
  344.     int            arrayhigh;
  345.     int            arraylen;
  346.  /* public: */
  347. };
  348.  
  349. /* ----------------
  350.  *  ArrayRef:
  351.  *    refelemtype    - type of the element referenced here
  352.  *    refelemlength    - length of that type
  353.  *    refelembyval    - can you pass this element type by value?
  354.  *    refindexpr    - expression that evaluates to array index
  355.  *    refexpr        - the expression that evaluates to an array
  356.  * ----------------
  357.  */
  358. class (ArrayRef) public (Expr) {
  359.  /* private: */
  360.     inherits1(Expr);
  361.     int            refattrlength;
  362.     int            refelemlength;
  363.     ObjectId        refelemtype;
  364.     bool            refelembyval;
  365.     LispValue        refindexpr;
  366.     LispValue        refexpr;
  367. };
  368. #endif /* PrimNodesIncluded */
  369.